<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<!--用户专业表单-->
<div class="easyui-layout" data-options="fit:true">
	<div class="TableTitle" data-options="region:'north',border:false">
		<span class="label label-primary"> <c:if
				test="${pageset.operateType==1}">新增${JSP_Messager_Title}记录</c:if> <c:if
				test="${pageset.operateType==2}">修改${JSP_Messager_Title}记录</c:if> <c:if
				test="${pageset.operateType==0}">浏览${JSP_Messager_Title}记录</c:if>
		</span>
	</div>
	<div data-options="region:'center'">
		<form id="dom_formUsermajor">
			<input type="hidden" id="entity_id" name="id" value="${entity.id}">
			<table class="editTable">
				<tr>
					<td class="title">选择专业</td>
					<td colspan="3"><select id="majorid">
							<c:forEach items="${majors}" var="node">
								<option value="${node.id}">${node.title}</option>
							</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td class="title">加载状态:</td>
					<td colspan="3" id="processId">等待开始</td>
				</tr>
			</table>
		</form>
	</div>
	<div data-options="region:'south',border:false">
		<div class="div_button" style="text-align: center; padding: 4px;">
			<a id="dom_add_entityUsermajor" href="javascript:void(0)"
				iconCls="icon-save" class="easyui-linkbutton">开始加载</a> <a
				id="dom_cancle_formUsermajor" href="javascript:void(0)"
				iconCls="icon-cancel" class="easyui-linkbutton"
				style="color: #000000;">取消</a>
		</div>
	</div>
</div>
<script type="text/javascript">
	var submitAddActionUsermajor = 'usermajor/add.do';
	var submitEditActionUsermajor = 'usermajor/edit.do';
	var currentPageTypeUsermajor = '${pageset.operateType}';
	var submitFormUsermajor;
	$(function() {
		//表单组件对象
		submitFormUsermajor = $('#dom_formUsermajor').SubmitForm({
			pageType : currentPageTypeUsermajor,
			grid : gridUsermajor,
			currentWindowId : 'winUsermajor'
		});
		//关闭窗口
		$('#dom_cancle_formUsermajor').bind('click', function() {
			$('#winUsermajor').window('close');
		});
		//提交新增数据
		$('#dom_add_entityUsermajor').bind('click', function() {
			$.post('usermajor/loadUserMajors.do', {
				'majorid' : $('#majorid').val()
			}, function(flag) {
				if (flag.STATE == 0) {
					loadProsess();
				} else {
					var str = MESSAGE_PLAT.ERROR_SUBMIT + flag.MESSAGE;
					$.messager.alert(MESSAGE_PLAT.ERROR, str, 'error');
				}
			}, 'json');
		});
	});

	function loadProsess() {
		$.post('usermajor/loadUserMajorsProcess.do', {
			'majorid' : $('#majorid').val()
		}, function(flag) {
			if (flag.isRun) {
				$('#processId').text(flag.i + "/" + flag.all + ":" + flag.msg);
				setTimeout(loadProsess, 1000);
			} else {
				$('#processId').text("完成" + flag.msg);
				$(gridUsermajor).datagrid('reload');
			}
		}, 'json');
	}
//-->
</script>